<extend name="Layout/ins_page_nojs" />

<block name="head"></block>
<block name="js"></block>

<block name="content">
    <!--content begin-->

        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <link type="text/css" rel="stylesheet" 	href="/Public/CSS/Report/ClassicReport/powerFloat.css" />
        <link type="text/css" rel="stylesheet" 	href="/Public/CSS/Report/ClassicReport/xmenu.css" />
        <link type="text/css" rel="stylesheet" 	href="/Public/CSS/Report/ClassicReport/main.css" />
        <script type="text/javascript" src="/Public/Scripts/Report/ClassicReport/jquery-1.7.2.min.js"></script>
        <script type="text/javascript" src="/Public/Scripts/Report/ClassicReport/jquery-powerFloat-min.js"></script>
        <script type="text/javascript" src="/Public/Scripts/Report/ClassicReport/jquery-xmenu.js"></script>
        <script type="text/javascript" src="/Public/Scripts/Report/ClassicReport/jquery-xmenu-option.js"></script>
        <link rel="stylesheet" type="text/css" href="/Public/Scripts/Report/ClassicReport/datepickup/tcal.css" />
        <link rel="stylesheet" type="text/css" href="/Public/CSS/Report/ClassicReport/xtable.css" />
        <script type="text/javascript" src="/Public/Scripts/Report/ClassicReport/datepickup/tcal.js"></script>
        <script language="javascript" type="text/javascript" src="/Public/Scripts/Report/ClassicReport/tablesort2/jquery.tablesorter.min.js"></script>

        <script type="text/javascript">
            $(document).ready(function() {
                $("#mytable").tablesorter({
                    headers: {
                        0:{sorter:"string"},
                        1:{sorter:"string"},
                        2:{sorter:"currency"},
                        3:{sorter:"currency"},
                        4:{sorter:"currency"},
                        5:{sorter:"currency"},
                        6:{sorter:"currency"}}
                });
            });
        </script>

        <style>
            .div-inline{ display:inline}
        </style>
        <style>
            body{text-align:center}
            .divcss5{margin:0 auto;width:600px;height:100px;border:1px solid #000}
        </style>

    <?php
$FromDate=date("m/",time())."01".date("/Y",time());
if(!empty($_GET['FromDate'])){ $FromDate=$_GET["FromDate"]; }
$ToDate=date("m/d/Y", strtotime("+1 months", strtotime(date("m/",time())."01".date("/Y",time()))));
if(!empty($_GET['ToDate'])){ $ToDate=$_GET["ToDate"]; }
$selectdeptidden="ALL";

$sqlconnection = $sqlserver->connenctObj;

if ($selectdeptidden!='ALL') {
$result1=odbc_do($sqlconnection,$namequery);
$maxi1= odbc_num_rows($result1);
$options1=array();
while($row1=odbc_fetch_row($result1)){
    $options1[] = iconv ("gb2312","utf-8",odbc_result($result1, 1));
}
}
?>

    <div id="main">
        <div id="lead" >

            <p>
            <form id="form1" name="form1" method="get" action="Report/classic3/">
                <br>
                <div  class="div-inline" > 开始时间
                    <input type="text" name="FromDate" class="tcal" value="<?php echo date('m/',time()).'01'.date('/Y',time());  $BeginDate=date('Y-m-01', strtotime(date('Y-m-d')));?>" /></div>
                <div  class="div-inline">
                    结束时间
                    <input type="text" name="ToDate" class="tcal" value="<?php echo date('m/',time()).'01'.date('/Y',time());  $BeginDate=date('Y-m-02', strtotime(date('Y-m-d')));?>" /></div>

        </div>


        <div  class="div-inline" >  <input type="submit" name="Submit" value="提交" /> </div>

        </form>

    </div>
    </p>

    <p>


        <?php


$sqlquery="select  t0.Cardcode,dbo.BPcontact(t0.Cardcode,'CardName') CardName,SUM(Quantity) SUMQTY,SUM(linetotal) SUMPRICE ,sum(isnull([linetotal],0)-isnull([bankcharge],0)-isnull([calclineStockprice],0)-isnull([calcexpressfee],0)-isnull([addexpressfee],0)-isnull([giftcount],0)-isnull([giftaddexpressfee],0)-isnull([calctax],0)) PROFIT,sum([calctax]) SUMTAX from ax_reportx T0 left join oitm T1 ON T0.Itemcode=T1.itemcode where t0.docdate>='".$FromDate."' and t0.docdate<='".$ToDate."' ";

        if($selectdeptidden != "ALL")
        {
            $sqlquery = $sqlquery.$CardLimitquery;
        }

        $sqlquery=$sqlquery." group by  t0.CardCode";
        $arr=odbc_do($sqlconnection,$sqlquery);

        var_dump($arr);

        ?>
    <div>
        <table border="1"  id="mytable" cellspacing="0" class="divcss5" ><thead>
        <tr >
            <th style="width:12%"><div align="center">平台</div></th><th  style="width:12%"><div align="center">数量</div></th> <th  style="width:12%"><div align="center">销售金额</div></th> <th  style="width:12%" ><div align="center">销售毛利</div></th><th  style="width:12%" ><div align="center">毛利率%</div></th><th style="width:8%" ><div align="center">税总计</div></th>
        </tr>
        </thead>
            <tbody>

            <?php
// 使用while语句循环mysql_fetch_array()函数返回的数组
while($result=odbc_fetch_array($arr)){
?>

            <tr align="center">
                <td><?php echo iconv("gb2312","utf-8//IGNORE",$result['CardName']);?></td>
                <td><?php echo number_format(round($result['SUMQTY'],0));?></td>
                <td><?php echo number_format(round($result['SUMPRICE'],2));?></td>
                <td><?php if (round($result['PROFIT'],2)<0){echo "<font color='FF6633'>".number_format(round($result['PROFIT'],2))."</font>" ;} else {echo "<font color='000099'>".number_format(round($result['PROFIT'],2))."</font>"; } ?></td>
                <td><?php if (round($result['PROFIT'],2)<0){echo "<font color='FF6633'>".round($result['PROFIT']/$result['SUMPRICE']*100,2)."</font>" ;} else {echo "<font color='000099'>".round($result['PROFIT']/$result['SUMPRICE']*100,2)."</font>"; } ?></td>
                <td><?php echo number_format(round($result['SUMTAX'],2));?></td>
            </tr>

            <?php
} // 结束while循环
?>
            </tbody>
        </table>

    </p>


    <!--content end-->
</block>